package com.test.atomikost.service.impl;

import com.test.atomikost.dao.mysql.AccessPointDao;
import com.test.atomikost.dao.oracle.MetadataBmzzDao;
import com.test.atomikost.model.TAccessPoint;
import com.test.atomikost.model.TMetadataBmzz;
import com.test.atomikost.service.IAccessPointService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.List;

/**
 * Created by Administrator on 16-3-29.
 */
@Service
@Transactional
public class AccessPontServiceImpl implements IAccessPointService {

    @Resource
    private AccessPointDao accessPointDao;

    @Resource
    private MetadataBmzzDao metadataBmzzDao;


    @Override
    public List<Map<String,String>> queryAccessPointId(String accessPointId,String bmzzId) {
        Map<String,String> mapAccessPoint = accessPointDao.queryAccessPointId(accessPointId);
        Map<String,String> mapBmzz = metadataBmzzDao.queryMetadataBmzzId(bmzzId);
        List<Map<String,String>> list = new ArrayList<Map<String, String>>();
        list.add(mapAccessPoint);
        list.add(mapBmzz);
        return list;
    }

    @Override
    public String saveData() {

        TAccessPoint accessPoint = new TAccessPoint();
        accessPoint.setAccessPointId("ap_113");
        accessPoint.setAccessPointName("ap_113");
        accessPoint.setCenCtrllId("CenterControllerCISP");
        accessPoint.setCreateTime(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
        accessPoint.setDel("0");
        accessPoint.setIp("127.0.0.1");
        accessPoint.setMemo("测试");
        accessPoint.setPort("8080");
        accessPoint.setState("1");
        accessPoint.setUpdateTime(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
        System.out.println("开始新增接入点的数据");
        accessPointDao.saveAccessPoint(accessPoint);
        TMetadataBmzz metadataBmzz = new TMetadataBmzz();
        metadataBmzz.setBfdwId("JSJ");
        metadataBmzz.setGjzId("");
        metadataBmzz.setId("23DQE/BMZZ0100");
        metadataBmzz.setSxlbId("1");
        metadataBmzz.setTgdwId("JSJ");
        metadataBmzz.setWjlx("JPG");
        metadataBmzz.setZzBhFl("");
        metadataBmzz.setZzBhGs("邮编（6位）+日期（8位）+XXXX");
        metadataBmzz.setZzbz("350200201508170000");
        metadataBmzz.setZzmc("中华人民共和国建筑工程施工许可证");
        metadataBmzz.setZzztId("1");
        metadataBmzz.setYxqx("永久");
        System.out.println("开始新增资源目录的数据");
        metadataBmzzDao.saveMetadataBmzz(metadataBmzz);

        return "true";
    }
}
